package com.jsy.mini12306.user.controller;

import com.jsy.mini12306.common.entity.Passenger;
import com.jsy.mini12306.user.vo.PassengerVO;
import com.jsy.mini12306.user.service.PassengerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 乘客表(Passenger)表控制层
 *
 * @author: SongyangJi
 * @since: 2021-09-01 00:43:43
 * @description:
 */

@Slf4j
@RestController
@RequestMapping("passenger")
public class PassengerController {
    /**
     * 服务对象
     */
    @Resource
    private PassengerService passengerService;

    @GetMapping("/{passengerId}")
    public ResponseEntity<Passenger> getPassenger(@PathVariable String passengerId) {
        return ResponseEntity.ok(passengerService.getById(passengerId));
    }

    @PostMapping("/newPassenger")
    public ResponseEntity<Boolean> postPassenger(@RequestBody Passenger passenger) {
        return ResponseEntity.ok(passengerService.save(passenger));
    }



    @PostMapping("/login")
    public ResponseEntity<Passenger> login(@RequestBody PassengerVO passenger) {
        return ResponseEntity.ok(passengerService.login(passenger));
    }


}
